home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Main.bin / gc_md.h < prev    next >
C/C++ Source or Header  |  1998-09-15  |  4KB  |  101 lines

  1. /*
  2.  * @(#)gc_md.h    1.5 98/07/01
  3.  *
  4.  * Copyright 1995-1998 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  * 
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14.  
  15. #ifndef _GC_MD_H_
  16. #define _GC_MD_H_
  17.  
  18. /*---- Win32 defines for garbage collection ----*/
  19.  
  20. #ifdef DEBUG
  21. /* local debug & error checking flag */
  22. /* #define LDEBUG  1 */
  23. /* Define below if you want lots of verbose info at runtime */
  24. /* #define TRACEGC 1 */
  25. /* define to send strs to debugger (on Mac) */
  26. #undef DPRINTFDEBUG
  27. #endif
  28.  
  29. #ifdef TRACEGC
  30. /* define below for REALLY detailed print */
  31. #undef TRACEMARK
  32. #undef TRACEFREE
  33. #undef TRACECOMPACT
  34. #undef PDEBUG
  35. #endif
  36.  
  37. #ifdef PAGED_HEAPS  /************ PAGED HEAPS: ********************/
  38.  
  39. /* In order for the OS to allocate many chunks of aligned memory, leave a little
  40.  * room at the end of our chunks that the OS can use for it's own purposes for 
  41.  * the next allocation.
  42.  */ 
  43. #define OS_BLOCK_OVERHEAD  0        /* in bytes */
  44.  
  45. /* On MacOS for instance, sysMemAlign allocates a block that may not be aligned
  46.  * and returns an aligned pointer into that block.  We may be able to use that
  47.  * space, so keep track of it.
  48.  */
  49. #undef WASTED_SPACE_IN_LEADER
  50.  
  51. /* TUNING ISSUES:
  52.  * On machines that don't have a real memalign, WASTED_SPACE_IN_LEADER will be
  53.  * true.  So chosing a page size is a trade off between wasting up to a page
  54.  * per chunk to achive alignment, and using up memory for a large page map.
  55.  * Note that a page is the smallest ammount that the gc will request from the
  56.  * OS, so it should be reasonable (eg. not 1M on a 4M machine!)
  57.  *
  58.  * AlignmentWaste(worst) = PAGE_ALIGNMENT / MIN_XXX_PAGES * 
  59.  *                         memory used / PAGE_ALIGNMENT;
  60.  *                       = memory used / MIN_XXX_PAGES;
  61.  * AlignmentWaste(avg)   = memory used / (2 * MIN_XXX_PAGES);
  62.  *
  63.  * PageMapSize(worst) = address space / PAGE_ALIGNMENT * 8
  64.  *
  65.  * MITIGATING FACTORS:
  66.  *   A) The allocator tries to store the mark bits for a chunk in the aligment
  67.  *      waste area.  Note that we need two mark bits for every two words, so:
  68.  *          MarkBitsSize = memory used / 32;
  69.  *      There are various round-off issues, but accounting for the savings of 
  70.  *      storing the marks in the waste:
  71.  * AlignmentWaste(mitigated_avg) = memory used / (2 * MIN_XXX_PAGES) - 
  72.  *                                 memory used / 32;
  73.  *      So, if you keep    MIN_XXX_PAGES > 16, AlignmentWaste approaches zero.
  74.  *
  75.  *   B) The page map is only large enough to span the pages handed to us by the
  76.  *      OS, and it's unlikly that the OS will give us some pages at 0x00000000,
  77.  *      then a few more pages near 0xFFFFFFFF.
  78.  *
  79.  * So, keep MIN_XXX_PAGES > 16, maximize PAGE_ALIGNMENT (especially if address 
  80.  * space is large), but try to keep PAGE_ALIGNMENT * MIN_XXX_PAGES to a
  81.  * size that the OS will usually be able to allocate.
  82.  *
  83.  */
  84. #define PAGE_ALIGNMENT        (64 * 1024)  /* page size is the same. */
  85.  
  86. /* # of bits to shift a pointer to get a page number
  87.  * 2 ^ PTR_2_PAGE_SHIFT == PAGE_ALIGNMENT  */
  88. #define PTR_2_PAGE_SHIFT    (16)
  89.  
  90.  
  91. #ifdef LDEBUG        /* stress testing */
  92. #define MIN_OBJ_PAGES (2)      /* min # of pages to allocate for objects */
  93. #define MIN_HANDLE_PAGES (2)      /* min # of pages to allocate for handles */
  94. #else
  95. #define MIN_OBJ_PAGES (32)      /* min # of pages to allocate for objects */
  96. #define MIN_HANDLE_PAGES (8)      /* min # of pages to allocate for handles */
  97. #endif /* LDEBUG */
  98.  
  99. #endif  /************ END PAGED HEAPS ********************/
  100. #endif /* !_GC_MD_H_ */
  101.